import { createRequest } from '/@/api/service';
const module = 'ib/openapi/v1/auth/';

/**
 * @function 获取公钥
 * @param data
 * @param header
 * @returns {Promise}
 */
function GET_PUBLIC_KEY(
  data: OpenApiAuth.GetPublicKeyReq,
  header: object = {},
): Promise<OpenApiAuth.GetPublicKeyResp> {
  return createRequest(`${process.env.APP_API_URL}${module}getPublicKey`, data, header, 'POST');
}

/**
 * @function 生成单点登录token
 * @param data
 * @param header
 * @returns {Promise}
 */
function GENERATE_TOKEN(
  data: OpenApiAuth.GenerateTokenReq,
  header: object = {},
): Promise<OpenApiAuth.GenerateTokenResp> {
  return createRequest(`${process.env.APP_API_URL}${module}generateToken`, data, header, 'POST');
}

export { GET_PUBLIC_KEY, GENERATE_TOKEN };
